﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Algorithm
{
    public static class Helper
    {
        public static void Exchange<T>(T[] array, int i, int j)
        {
            T tmp = array[i];
            array[i] = array[j];
            array[j] = tmp;
        }

        public static void PrintArray<T>(T[] array)
        {
            Console.Write(Environment.NewLine);

            for (int i = 0; i < array.Length; i++)
            {
                Console.Write("  <<  ");
                Console.Write(array[i]);
                Console.Write("      ");
            }
        }

        public static int[] RandomIntArray(int length, int minNum, int maxNum)
        {
            if (length <= 0)
            {
                throw new ArgumentException("Length less then 0.");
            }

            Random rand = new Random();

            int[] result = new int[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = rand.Next(minNum, maxNum);
            }

            return result;
        }
    }
}
